export const treeList = [
  {
    address: "",
    companyId: 1,
    managerList: [
      {
        account: "CZQ2",
        businessId: 9999,
        businessUid: "9999202406151129257252JpFHm",
        email: "",
        id: 83,
        invoiceAccount: "",
        isDisabled: true,
        isOrganizeSuper: true,
        managerGroupIds: [
          5
        ],
        masterBUId: "999920240611203700064zl5gVo",
        masterManagerVo: {
          masterBUId: "999920240611203700064zl5gVo",
          organizeId: 1
        },
        masterOrganizeId: 1,
        mobile: "13200000089",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "1111",
        organizeIds: [
          1
        ],
        password: "ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f",
        realName: "陈志琦",
        remark: "",
        roleIds: [
          7
        ],
        telephone: ""
      },
      {
        account: "CC123",
        businessId: 9999,
        businessUid: "9999202405301556533486Y5VH4",
        email: "",
        id: 73,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [
          12
        ],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 1,
        mobile: "13696968596",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "1111",
        organizeIds: [
          1,
          3
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "曹操",
        remark: "",
        roleIds: [
          8
        ],
        telephone: ""
      },
      {
        account: "CC124",
        businessId: 9999,
        businessUid: "999920240611203700064zl5gVo",
        email: "",
        id: 82,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [
          12
        ],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 1,
        mobile: "13696968588",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: "2024-03-23 00:00:00",
        officeJob: "1111",
        organizeIds: [
          1
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "曹操1",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "LSM001",
        businessId: 9999,
        businessUid: "999920240617161926998JvGA1D",
        email: "",
        id: 85,
        invoiceAccount: "",
        isDisabled: true,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 1,
        mobile: "13111111111",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          1
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "李世民",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "Admin",
        businessId: 9999,
        businessUid: "1",
        email: "",
        id: 1,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [
          7,
          23
        ],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: null,
        mobile: "",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          1
        ],
        password: "03ac62c784d0109cecbcecb6e7268d38dece4fa61017d68728c4acebac76da67",
        realName: "系统管理员",
        remark: "",
        roleIds: [],
        telephone: ""
      }
    ],
    managerNum: 14,
    organizeId: 1,
    organizeMaster: {
      id: 9,
      managerBAccount: "CZQ2",
      managerBUId: "9999202406151129257252JpFHm",
      managerBUName: "陈志琦",
      organizeId: 1
    },
    organizeName: "XXX水务集团有限公司",
    organizePId: 0,
    organizePermission: null,
    remark: "",
    telephone: "78787"
  },
  {
    address: "",
    companyId: 1,
    managerList: [
      {
        account: "hjw",
        businessId: 9999,
        businessUid: "999920240229104131965sjmATv",
        email: "",
        id: 66,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: true,
        managerGroupIds: [
          7
        ],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 2,
        mobile: "13200000255",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3
        ],
        password: "ee79976c9380d5e337fc1c095ece8c8f22f91f306ceeb161fa51fecede2c4ba1",
        realName: "黄建伟",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "ailun",
        businessId: 9999,
        businessUid: "999920240530155737355XdjTjR",
        email: "",
        id: 75,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "9999202405301556533486Y5VH4",
        masterManagerVo: {
          masterBUId: "9999202405301556533486Y5VH4",
          organizeId: 1
        },
        masterOrganizeId: 4,
        mobile: "13200000000",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "342e489174cc8579d038ea97683b010fee86de2c274d2a2eafcb595b213e643f",
        realName: "ailun",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "czq",
        businessId: 9999,
        businessUid: "9999202406071729479303yasi2",
        email: "",
        id: 79,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 3,
        mobile: "13200000004",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          70
        ],
        password: "ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f",
        realName: "czq",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "AFN123",
        businessId: 9999,
        businessUid: "999920240530153813660Br9KA5",
        email: "",
        id: 71,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 70,
        mobile: "13696968578",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          70
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "阿菲娜",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "BB123",
        businessId: 9999,
        businessUid: "9999202405301556211434Oi23M",
        email: "",
        id: 72,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 3,
        mobile: "13269698569",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "1111",
        organizeIds: [
          3
        ],
        password: "ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f",
        realName: "宝宝",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "222323",
        businessId: 9999,
        businessUid: "999920240530155857628ziDGtN",
        email: "",
        id: 76,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13696968598",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "4954e0903b3135ca92254b7b5e3627c3d43247d8ce975fae62439357cf28f91e",
        realName: "宝宝2",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "BB3",
        businessId: 9999,
        businessUid: "999920240530160137821kaTlCy",
        email: "",
        id: 77,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13698555588",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "965f69baefb60286c60262b40dcf40717a2227eef5db00c9b717d5de24453511",
        realName: "宝宝3",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "CC123",
        businessId: 9999,
        businessUid: "9999202405301556533486Y5VH4",
        email: "",
        id: 73,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [
          12
        ],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 1,
        mobile: "13696968596",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "1111",
        organizeIds: [
          1,
          3
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "曹操",
        remark: "",
        roleIds: [
          8
        ],
        telephone: ""
      },
      {
        account: "DD123",
        businessId: 9999,
        businessUid: "999920240530155714274WJNKki",
        email: "",
        id: 74,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13269698596",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "e44b119b23ce33d3a678cfed8a90d8683e570126840a81f15fc0534150c31242",
        realName: "弟弟",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "lfy",
        businessId: 9999,
        businessUid: "999920240229104150117pxYdDz",
        email: "",
        id: 67,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [
          7
        ],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 2,
        mobile: "13232333332",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          2,
          3
        ],
        password: "ee79976c9380d5e337fc1c095ece8c8f22f91f306ceeb161fa51fecede2c4ba1",
        realName: "刘飞宇",
        remark: "",
        roleIds: [],
        telephone: ""
      }
    ],
    managerNum: 10,
    organizeId: 3,
    organizeMaster: {
      id: 2,
      managerBAccount: "hjw",
      managerBUId: "999920240229104131965sjmATv",
      managerBUName: "黄建伟",
      organizeId: 3
    },
    organizeName: "分公司",
    organizePId: 2,
    organizePermission: {
      businessUids: "",
      id: 26,
      isEnable: false,
      managerOrganizeList: [],
      organizeId: 3,
      permissionType: 1
    },
    remark: "0571-8150876",
    telephone: "admin"
  },
  {
    address: "",
    companyId: 1,
    managerList: [
      {
        account: "ailun",
        businessId: 9999,
        businessUid: "999920240530155737355XdjTjR",
        email: "",
        id: 75,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "9999202405301556533486Y5VH4",
        masterManagerVo: {
          masterBUId: "9999202405301556533486Y5VH4",
          organizeId: 1
        },
        masterOrganizeId: 4,
        mobile: "13200000000",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "342e489174cc8579d038ea97683b010fee86de2c274d2a2eafcb595b213e643f",
        realName: "ailun",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "222323",
        businessId: 9999,
        businessUid: "999920240530155857628ziDGtN",
        email: "",
        id: 76,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13696968598",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "4954e0903b3135ca92254b7b5e3627c3d43247d8ce975fae62439357cf28f91e",
        realName: "宝宝2",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "BB3",
        businessId: 9999,
        businessUid: "999920240530160137821kaTlCy",
        email: "",
        id: 77,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13698555588",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "965f69baefb60286c60262b40dcf40717a2227eef5db00c9b717d5de24453511",
        realName: "宝宝3",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "DD123",
        businessId: 9999,
        businessUid: "999920240530155714274WJNKki",
        email: "",
        id: 74,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 4,
        mobile: "13269698596",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          4
        ],
        password: "e44b119b23ce33d3a678cfed8a90d8683e570126840a81f15fc0534150c31242",
        realName: "弟弟",
        remark: "",
        roleIds: [],
        telephone: ""
      }
    ],
    managerNum: 4,
    organizeId: 4,
    organizeMaster: null,
    organizeName: "营业所",
    organizePId: 16,
    organizePermission: null,
    remark: "0571-8150876",
    telephone: "admin"
  },
  {
    address: "",
    companyId: 1,
    managerList: [
      {
        account: "czq",
        businessId: 9999,
        businessUid: "9999202406071729479303yasi2",
        email: "",
        id: 79,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 3,
        mobile: "13200000004",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          70
        ],
        password: "ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f",
        realName: "czq",
        remark: "",
        roleIds: [],
        telephone: ""
      },
      {
        account: "AFN123",
        businessId: 9999,
        businessUid: "999920240530153813660Br9KA5",
        email: "",
        id: 71,
        invoiceAccount: "",
        isDisabled: false,
        isOrganizeSuper: false,
        managerGroupIds: [],
        masterBUId: "999920240229104131965sjmATv",
        masterManagerVo: {
          masterBUId: "999920240229104131965sjmATv",
          organizeId: 3
        },
        masterOrganizeId: 70,
        mobile: "13696968578",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          3,
          70
        ],
        password: "6118da4cf197f1be45f9a6463019c70bb28f53d297f385df92f4840eee58d6ec",
        realName: "阿菲娜",
        remark: "",
        roleIds: [],
        telephone: ""
      }
    ],
    managerNum: 2,
    organizeId: 70,
    organizeMaster: {
      id: 1,
      managerBAccount: "hjw",
      managerBUId: "999920240229104131965sjmATv",
      managerBUName: "黄建伟",
      organizeId: 70
    },
    organizeName: "杭州分公司",
    organizePId: 1,
    organizePermission: {
      businessUids: "999920240229104131965sjmATv",
      id: 17,
      isEnable: true,
      managerOrganizeList: [
        {
          businessUid: "999920240229104131965sjmATv",
          id: null,
          organizeId: 3
        }
      ],
      organizeId: 70,
      permissionType: 1
    },
    remark: "",
    telephone: "136952255"
  },
  {
    address: "",
    companyId: 1,
    managerList: [
      {
        account: "lfy",
        businessId: 9999,
        businessUid: "999920240229104150117pxYdDz",
        email: "",
        id: 67,
        invoiceAccount: "",
        isDisabled: true,
        isOrganizeSuper: false,
        managerGroupIds: [
          7
        ],
        masterBUId: "",
        masterManagerVo: null,
        masterOrganizeId: 2,
        mobile: "13232333332",
        mobileShort: "",
        officeArea: null,
        officeEntryDate: null,
        officeJob: "",
        organizeIds: [
          2,
          3
        ],
        password: "ee79976c9380d5e337fc1c095ece8c8f22f91f306ceeb161fa51fecede2c4ba1",
        realName: "刘飞宇",
        remark: "",
        roleIds: [],
        telephone: ""
      }
    ],
    managerNum: 10,
    organizeId: 2,
    organizeMaster: null,
    organizeName: "水务公司",
    organizePId: 1,
    organizePermission: {
      businessUids: "",
      id: 27,
      isEnable: false,
      managerOrganizeList: [],
      organizeId: 2,
      permissionType: 1
    },
    remark: "0571-8150876",
    telephone: "admin"
  },
  {
    address: "",
    companyId: 1,
    managerList: [],
    managerNum: 0,
    organizeId: 71,
    organizeMaster: null,
    organizeName: "测试公司",
    organizePId: 2,
    organizePermission: {
      businessUids: "",
      id: 15,
      isEnable: true,
      managerOrganizeList: [],
      organizeId: 71,
      permissionType: 0
    },
    remark: "",
    telephone: ""
  },
  {
    address: "",
    companyId: 1,
    managerList: [],
    managerNum: 0,
    organizeId: 80,
    organizeMaster: null,
    organizeName: "测试公司下级",
    organizePId: 71,
    organizePermission: {
      businessUids: "",
      id: 30,
      isEnable: false,
      managerOrganizeList: [],
      organizeId: 80,
      permissionType: 1
    },
    remark: "",
    telephone: ""
  }
]

export const metaTree = (data, id = 'id', pid = 'pid', label = false) => {
  let parents = data.filter((p) => p[pid] === 0),
    children = data.filter((c) => c[pid] !== 0);
  const dataToTree = (parents, children) => {
    parents.map((p) => {
      if (label) {
        p.value = p[id]
        p.label = p[label]
      }
      p.id = p[id]
      p.pid = p[pid]
      children.map((c, i) => {
        if (c[pid] === p[id]) {
          let _c = JSON.parse(JSON.stringify(children));
          _c.splice(i, 1);
          dataToTree([c], _c);
          if (p.children) {
            p.children = [...p.children, c];
          } else {
            p.children = [c];
          }
        }
      });
    });
  };
  dataToTree(parents, children);
  return parents;
};


export function myFilter(treeList) {
  let hasChild = false;
  if (treeList.length === 0) {
    return hasChild;
  }
  for (let i = 0; i < treeList.length; i++) {
    let treeItme = treeList[i]
    console.log("1111,treeItem", treeItme)
    if (!treeItme.organizeId) {
      console.log("2222,treeItem", treeItme)
      hasChild = true;
      continue;
    }

    if (treeItme.children) {
      const b = myFilter(treeItme.children);
      if (b) {
        hasChild = true;
      }
    }

    if (!treeItme.children) {
      i--;
      treeList.splice(i, 1);
    } else {
      hasChild = true;
    }
  }
  return hasChild;
}